<?php
include '../../auth/ceklogin.php';
include '../../sql/conn.php';

$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset = ($page-1)*$rows;
/*
$namaCustomer = " namaCustomer like '%%'";
$alamatCustomer = '';
$attnCustomer = '';

if (isset($_POST['ref']))
{
    $ref = $_POST['ref'];
    $ref = explode('&',$ref);
    
    //nama customer
    $namaCustomer = $ref[0];
    $namaCustomer = explode("=", $namaCustomer);
    $namaCustomer = $namaCustomer[1];
    
    //alamat customer
    $alamatCustomer = $ref[1];
    $alamatCustomer = explode("=",$alamatCustomer);
    $alamatCustomer = $alamatCustomer[1];
    
    //alamat customer
    $attnCustomer = $ref[2];
    $attnCustomer = explode("=",$attnCustomer);
    $attnCustomer = $attnCustomer[1];
    
    if($namaCustomer!=''){
        $namaCustomer = " namaCustomer like '%".$namaCustomer."%'";
    }else{
        $namaCustomer = " namaCustomer like '%%'";
    }
    
    if($alamatCustomer!=''){
        $alamatCustomer = " AND alamatCustomer LIKE '%".$alamatCustomer."%'";
    }
    
    if($attnCustomer!=''){
        $attnCustomer = " AND attnCustomer LIKE '%".$attnCustomer."%'";
    }
}
*/
$rs = mysql_query("select count(*) from wo where $no_wo $namaCustomer $alamatCustomer $attnCustomer");  
$row = mysql_fetch_row($rs);  
$result["total"] = $row[0];  
  
$rs = mysql_query("select * from customer WHERE $namaCustomer $alamatCustomer $attnCustomer limit $offset,$rows");  
  
$items = array();  
while($row = mysql_fetch_object($rs)){  
    array_push($items, $row);  
}  
$result["rows"] = $items;  
  
echo json_encode($result);  
?>
